package com.matt.service.remoteCall.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.dotflat.staffExtend.po.*;
import com.matt.commons.dto.sso.AreaDTO;
import com.matt.commons.dto.sso.StaffDTO;
import com.matt.commons.model.StatusResponse;
import com.matt.commons.page.PagerQuery;
import com.matt.commons.utils.MapConvertUtil;
import com.matt.commons.utils.ModelUtil;
import com.matt.commons.utils.RemoteCallUtil;
import com.matt.domain.CreateStaff;
import com.matt.foundation.DO.TeacherDO;
import com.matt.foundation.dto.AreaDetailDTO;
import com.matt.foundation.dto.AreaSettingDTO;
import com.matt.foundation.dto.PlatformMenuDto;
import com.matt.service.remoteCall.DTO.*;
import com.matt.service.remoteCall.SsoCallService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jdom.DataConversionException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;

//import net.sf.json.JSONArray;
;import static com.matt.foundation.constant.RequestConstant.TICKET;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2018/6/25
 * *******************************
 */
@Service
@Slf4j
public class SsoCallServiceImpl implements SsoCallService {

    @Value("${server.sso.url}")
    private String ssoServerUrl;
    //默认系统ID
    private static final String PLATFORM_ID = "a4c8daf5e4cc4eddb6e5b2393b2db110";
    //字典字段
    private static final String GLOBAL_SETTING = "milepost_item";

    //WEB-系统ID
    private static final String DEFAULT_TERM_WEB = "a4c8daf5e4cc4eddb6e5b2393b2db110";
    //APP-系统ID
    private static final String DEFAULT_TERM_APP = "1ec8b3dcf312488ead30f26e736d024e";
    //小程序-系统ID
    private static final String DEFAULT_TERM_SMALL_ROUTINE = "a4c8daf5e4cc4eddb6e5b2393b2db110";

    //奈斯妈妈-系统ID
    private static final String XM_TERM_WEB = "e03cefb17be94bc09b6b5be501e036d8";
    //奈斯妈妈-移动端-系统ID
    private static final String XM_TERM_APP = "0389b7d8a13e488489cb2644820db1a7";

    //幼儿园_PC
    private static final String KG_TERM_WEB = "fb20f94dd2da4bd2abca4b468b02d15f";
    //幼儿园_APP
    private static final String KG_TERM_APP = "3e5e19e3bd844dda8196d4f57a1d58d0";

    private static final String[][] TERM_MAP = {
            {DEFAULT_TERM_WEB, DEFAULT_TERM_APP, DEFAULT_TERM_SMALL_ROUTINE },
            {XM_TERM_WEB, XM_TERM_APP, ""},
            {KG_TERM_WEB, KG_TERM_APP, ""},
    };

    @Override
    public StaffDTO getStaffDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_ticket_by_staff", null, ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public Map getStaffDTO2(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffIdByStaffJson", null, ticket, Map.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO getStaffDTO(String ticket, String staffId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_id_by_staff", ModelUtil.mapOf("staffId", staffId), ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffExtendInfoPO2 getStaffExtendDTO(String ticket, String staffId) {
        StaffExtendInfoPO2 staffExtendInfoPO = new StaffExtendInfoPO2();
        String call = RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffIdByStaffJson", ModelUtil.mapOf("staffId", staffId), ticket, String.class, "调用sso获取用户信息出错");
        JSONObject jsonObject = JSONObject.parseObject(call);
        String realName = jsonObject.getString("realName");//姓名
        Integer gender = jsonObject.getInteger("gender");//性别
        String idCard = jsonObject.getString("idCard");//身份证号
        Date birthTime = jsonObject.getDate("birthTime");//出生日期
        Integer age = jsonObject.getInteger("age");//年龄
        Integer types = jsonObject.getInteger("types");//年龄
        String contactInformation = jsonObject.getString("contactInformation");//联系方式
        String nationality = jsonObject.getString("nationality");//民族
        String homeAddress = jsonObject.getString("homeAddress");//家庭住址
        String province = jsonObject.getString("province");//省
        String city = jsonObject.getString("city");//市
        String district = jsonObject.getString("district");//区
        String detailedAddress = jsonObject.getString("detailedAddress");//详细地址
        String headImgUrl = jsonObject.getString("headImgUrl");//头像
        String currentAddress = jsonObject.getString("currentAddress");//现住住址
        String emergencyName = jsonObject.getString("emergencyName");//紧急联系人
        String emergencyMobile = jsonObject.getString("emergencyMobile");//紧急联系人
        String workFormPhoto = jsonObject.getString("workFormPhoto");//工作形象照
        String certificate = jsonObject.getString("certificate");//学历证书
        //String certificateEmployment = jsonObject.getString("certificateEmployment");//从业证书
        String file = jsonObject.getString("file");//附件
        String id = jsonObject.getString("id");//id
        String mobile = jsonObject.getString("mobile");//mobile
        Date physicalReportStart = jsonObject.getDate("physicalReportStart");//体检报告开始时间
        Date physicalReportEnd = jsonObject.getDate("physicalReportEnd");//体检报告结束时间
        String physicalReportFile = jsonObject.getString("physicalReportFile");//体检报告
        Date certificateClearanceStart = jsonObject.getDate("certificateClearanceStart");//无犯罪证明开始时间
        Date certificateClearanceEnd = jsonObject.getDate("certificateClearanceEnd");//无犯罪证明结束时间
        String certificateClearanceFile = jsonObject.getString("certificateClearanceFile");//无犯罪证明
        String introduction = jsonObject.getString("introduction");//无犯罪证明

        staffExtendInfoPO.setRealName(realName);
        staffExtendInfoPO.setGender(gender);
        staffExtendInfoPO.setIdCard(idCard);
        staffExtendInfoPO.setBirthTime(birthTime);
        staffExtendInfoPO.setAge(age);
        staffExtendInfoPO.setTypes(types);
        staffExtendInfoPO.setMobile(mobile);
        staffExtendInfoPO.setContactInformation(contactInformation);
        if(contactInformation==null){
            staffExtendInfoPO.setContactInformation(mobile);
        }
        staffExtendInfoPO.setNationality(nationality);
        staffExtendInfoPO.setHomeAddress(homeAddress);
        staffExtendInfoPO.setCurrentAddress(currentAddress);
        staffExtendInfoPO.setProvince(province);
        staffExtendInfoPO.setCity(city);
        staffExtendInfoPO.setDistrict(district);
        staffExtendInfoPO.setDetailedAddress(detailedAddress);
        staffExtendInfoPO.setHeadImgUrl(headImgUrl);
        staffExtendInfoPO.setEmergencyName(emergencyName);
        staffExtendInfoPO.setEmergencyMobile(emergencyMobile);
        staffExtendInfoPO.setWorkFormPhoto(workFormPhoto);
        staffExtendInfoPO.setCertificate(certificate);
//        staffExtendInfoPO.setCertificateEmployment(certificateEmployment);
        staffExtendInfoPO.setFile(file);
        staffExtendInfoPO.setId(id);

        staffExtendInfoPO.setPhysicalReportStart(physicalReportStart);
        staffExtendInfoPO.setPhysicalReportEnd(physicalReportEnd);
        staffExtendInfoPO.setPhysicalReportFile(physicalReportFile);
        staffExtendInfoPO.setCertificateClearanceStart(certificateClearanceStart);
        staffExtendInfoPO.setCertificateClearanceEnd(certificateClearanceEnd);
        staffExtendInfoPO.setCertificateClearanceFile(certificateClearanceFile);
        staffExtendInfoPO.setIntroduction(introduction);

        JSONArray staffChildPOList = jsonObject.getJSONArray("childList");
        List<StaffChildPO> staffChildPOList1 = new LinkedList<>();//教育信息 type=1
        List<StaffChildPO> staffChildPOList2 = new LinkedList<>();//从业证书 type=2
        List<StaffChildPO> staffChildPOList3 = new LinkedList<>();//工作履历 type=3
        List<StaffChildPO> staffChildPOList4 = new LinkedList<>();//教育信息 type=4
        List<StaffChildPO> staffChildPOList5 = new LinkedList<>();//体检报告 type=5
        List<StaffChildPO> staffChildPOList6 = new LinkedList<>();//无犯罪证明 type=6
        if(null!=staffChildPOList && staffChildPOList.size()>0){
            for (int i = 0; i < staffChildPOList.size(); i++) {
                JSONObject item = staffChildPOList.getJSONObject(i);
                Integer type = item.getInteger("type");
                if(null==type){
                    continue;
                }

                if(type==1){
                    String almaMater = item.getString("almaMater");//毕业院校
                    String educationalLevel = item.getString("educationalLevel");//学历层次
                    String major = item.getString("major");//所学专业
//                String certificate = item.getString("certificate");//学历证书

                    StaffChildPO staffChildPO = new StaffChildPO();
                    staffChildPO.setAlmaMater(almaMater);
                    staffChildPO.setEducationalLevel(educationalLevel);
                    staffChildPO.setMajor(major);
//                staffChildPO.setCertificate(certificate);
                    staffChildPOList1.add(staffChildPO);
                } else if(type==2){
                    Integer workingCertificate = item.getInteger("workingCertificate");//从业证书
                    Date certificationTime = item.getDate("certificationTime");//获证时间
                    Date expirationTime = item.getDate("expirationTime");//过期时间
                    String certificateEmployment = item.getString("certificateEmployment");//证书

                    StaffChildPO staffChildPO = new StaffChildPO();
                    staffChildPO.setWorkingCertificate(workingCertificate);
                    staffChildPO.setCertificationTime(certificationTime);
                    staffChildPO.setExpirationTime(expirationTime);
                    staffChildPO.setCertificateEmployment(certificateEmployment);
//                staffChildPO.setCertificate(certificate);
                    staffChildPOList2.add(staffChildPO);
                }else if(type==3){
                    String almaMater = item.getString("almaMater");//工作单位名称
//                item.getDate("startStopTime");//工作起止时间
                    Date startTime = item.getDate("startTime");//工作起止时间
                    Date stopTime = item.getDate("stopTime");//工作结束吧时间
                    String major = item.getString("major");//过期时间

                    StaffChildPO staffChildPO = new StaffChildPO();
                    staffChildPO.setAlmaMater(almaMater);
                    staffChildPO.setStartTime(startTime);
                    staffChildPO.setStopTime(stopTime);
                    staffChildPO.setMajor(major);
                    DateFormat fmt =new SimpleDateFormat("yyyy-MM-dd");
                    if(null!=startTime && null!=stopTime){
                        List<String> list = Arrays.asList(fmt.format(startTime),fmt.format(stopTime));
                        staffChildPO.setStartStopTime(list);
                    }
                    staffChildPOList3.add(staffChildPO);
                }else if(type==4){
                    String classesId = item.getString("classesId");//班级id
                    String classesName = item.getString("classesName");//班级名称
                    String positionHeld = item.getString("positionHeld");//担任岗位
                    Integer staffType = item.getInteger("staffType");//人员类型

                    StaffChildPO staffChildPO = new StaffChildPO();
                    staffChildPO.setClassesId(classesId);
                    staffChildPO.setClassesName(classesName);
                    staffChildPO.setPositionHeld(positionHeld);
                    staffChildPO.setStaffType(staffType);
                    staffChildPOList4.add(staffChildPO);
                }
            }
        }
        staffExtendInfoPO.setStaffChildPOList1(staffChildPOList1);
        staffExtendInfoPO.setStaffChildPOList2(staffChildPOList2);
        staffExtendInfoPO.setStaffChildPOList3(staffChildPOList3);
        staffExtendInfoPO.setStaffChildPOList4(staffChildPOList4);

        return staffExtendInfoPO;
    }

    @Override
    public StaffDTO getStaffDTOByPhone(String ticket, String phone) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_mobile_by_staff", ModelUtil.mapOf("mobile", phone), ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO updateStaff(String ticket, StaffDTO staffDTO) {
        Map map = MapConvertUtil.obejctToMap(staffDTO); // JSON.parseObject(JSON.toJSONString(staffDTO), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_staff", map, ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public StaffDTO updateStaff2(String ticket, StaffDTO staffDTO,List<String> roles,String paramJson) {
        Map map = MapConvertUtil.obejctToMap(staffDTO); // JSON.parseObject(JSON.toJSONString(staffDTO), Map.class);
        map.put("paramJson",paramJson);
        map.put("roles", roles);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_staff2", map, ticket, StaffDTO.class, "调用sso推送消息出错");
    }




    @Override
    public StaffDTO updateStaff3(String ticket,String paramJson) {
        Map map = new HashMap();
        map.put("paramJson",paramJson);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_staff3", map, ticket, StaffDTO.class, "调用sso推送消息出错");
    }



    @Override
    public StaffDTO quitStaff(String ticket, String staffId) {

        return quitStaff(ticket, null, staffId);
    }
    @Override
    public StaffDTO quitStaff(String ticket, String areaId, String staffId) {
        //TODO: 员工离职,需要根据ticket来圈定areaId
        Map params = ModelUtil.mapOf("staffId", staffId);
        if (StringUtils.isNotEmpty(areaId)){
            params.put("areaId", areaId);
        }
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/quitStaff", params, ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public StaffDTO staffEntry(String ticket, String staffId) {
        return staffEntry(ticket, null, staffId);
    }

    @Override
    public StaffDTO staffEntry(String ticket, String areaId, String staffId) {
        //TODO: 员工离职,需要根据ticket来圈定areaId
        Map params = ModelUtil.mapOf("staffId", staffId);
        if (StringUtils.isNotEmpty(areaId)){
            params.put("areaId", areaId);
        }
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/staffEntry", params, ticket, StaffDTO.class, "调用sso推送消息出错");

    }

    @Override
    public StaffDTO createStaff(String ticket, StaffDTO staffDTO) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO createStaff(String ticket, StaffDTO staffDTO, String[] roles) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        map.put("roles", Arrays.asList(roles));
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");

    }

    @Override
    public StaffDTO createStaff2(String ticket, StaffDTO staffDTO,String paramJson) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        map.put("paramJson",paramJson);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff2", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");
    }

    @Override
    public StaffDTO createStaff2(String ticket, StaffDTO staffDTO, List<String> roles,String paramJson) {
        Map map = MapConvertUtil.obejctToMap(staffDTO);
        map.put("roles", roles);
        map.put("paramJson",paramJson);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/createStaff2", map, ticket, StaffDTO.class, "调用sso获取用户信息出错");

    }

    @Override
    public Map resetPassword(String ticket, String oldPassword, String newPassword) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/update_password", ModelUtil.mapOf("oldPassword", oldPassword, "newPassword", newPassword), ticket, Map.class, "调用sso推送消息出错");
    }

    @Override
    public String forgetPassword(String phone, String verifyCode, String newPassword) {
        Map map = new HashMap();
        map.put("phone", phone);
        map.put("verifyCode", verifyCode);
        map.put("newPassword", newPassword);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/sms/forgetPassword", map, null, String.class, "调用sso推送消息出错");
    }

    @Override
    public String passLogin(String mobile, String password, String ip, int term, String platformId) {
        platformId = getTermType(term, platformId);

        Map map = new HashMap();
        map.put("platformId", platformId);
        map.put("password", password);
        map.put("ip", ip);
        map.put("mobile", mobile);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/passLogin", map, null, String.class, "调用sso推送消息出错");
    }


    @Override
    public String groupPassLogin(String mobile, String password, String ip, int term,String platformId) {
        platformId = getTermType(term,platformId);
        Map map = new HashMap();
        map.put("platformId", platformId);
        map.put("password", password);
        map.put("ip", ip);
        map.put("mobile", mobile);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/groupPassLogin", map, null, String.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String ticket, String permission) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getPermissionStaffDTOList", ModelUtil.mapOf("permission", permission), ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String ticket, String[] ids) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/ids_by_staff_list", ModelUtil.mapOf("staffIds", Arrays.asList(ids)), ticket, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffDTO> getStaffDTOList(String areaId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffDTOList", ModelUtil.mapOf("areaId", areaId), null, StaffDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Map getPermissionInfoV2(String ticket,String platformId) {
        return getPermissionInfoV2(ticket, 0, platformId);
    }

    @Override
    public Map getPermissionInfoV2(String ticket, int term,String platformId) {
        platformId = getTermType(term, platformId);
        Map map = new HashMap();
        map.put("platformId", platformId);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getPermissionInfoV2", map, ticket, Map.class, "调用sso推送消息出错");
    }

    @Override
    public RoleDTO getStaffRole(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffRole", null, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public RoleDTO setDefaultRole(String ticket, String roleId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setDefaultRole", ModelUtil.mapOf("roleId", roleId), ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO getDefaultRole(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getDefaultRole", null, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<RoleDTO> getStaffRoleList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffRoleList", null, ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    //TODO: 需要处理的接口
    @Override
    public List<RoleDTO> getStaffRoleList(String ticket, String staffId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffIdByRoleList", ModelUtil.mapOf("staffId", staffId), ticket, RoleDTO.class, "调用sso推送消息出错");

    }

    @Override
    public void setStaffRoleList(String ticket, String staffId, String[] roleIds) {
        RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setStaffRoleList", ModelUtil.mapOf("staffId", staffId, "roleIds", Arrays.asList(roleIds)), ticket, null, "调用sso推送消息出错");
    }

    @Override
    public List<PlatformMenuDto> getTermMenus(String ticket, int term,String platformId) {

        platformId = getTermType(term,platformId);

        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getTermMenus", ModelUtil.mapOf("platformId", platformId), ticket, PlatformMenuDto.class, "调用sso推送消息出错");

    }

    @Override
    public List<PlatformMenuDto> getRoleMenus(String ticket, String roleId, int term,String platformId) {
        platformId = getTermType(term,platformId);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/roleIdAndPlatformIdByTermMenus", ModelUtil.mapOf("platformId", platformId, "roleId", roleId), ticket, PlatformMenuDto.class, "调用sso推送消息出错");
    }

    @Override
    /**
     * 添加用户 园区 角色菜单关系
     */
    public RoleDTO setRoleMenus(String ticket, String roleId, String[] menuIds, int term,String platformId) {
        platformId = getTermType(term,platformId);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setRoleMenus", ModelUtil.mapOf("roleId", roleId, "menuIds", Arrays.asList(menuIds), "platformId", platformId), ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<RoleCountDO> getAreaRoles(String ticket, boolean staffCount) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaRoles", null, ticket, RoleCountDO.class, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO addAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaRole", map, ticket, RoleDTO.class, "调用sso推送消息出错");
    }

    @Override
    public void removeAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/removeAreaRole", map, ticket, null, "调用sso推送消息出错");

    }

    @Override
    public RoleDTO updateAreaRole(String ticket, RoleDTO role) {
        Map map = JSON.parseObject(JSON.toJSONString(role), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaRole", map, ticket, RoleDTO.class, "调用sso推送消息出错");

    }

//    @Override
//    public List<StaffDTO> getAreaStaffByRole(String ticket, String roleId, PagerQuery pagerQuery) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffByRole", ModelUtil.mapOf("pageNum",pagerQuery.getPageNum(),"pageSize",pagerQuery.getPageSize(),"roleId",roleId), ticket, StaffDTO.class, "调用sso推送消息出错");
//    }

    @Override
    public Boolean checkStaffPermission(String ticket, String[] permission) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/checkStaffPermission", ModelUtil.mapOf("permission", Arrays.asList(permission)), ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public Boolean send_sms(String mobile) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/sms/sendSms",  ModelUtil.mapOf("phone", mobile), null, Boolean.class, "调用sso获取园区出错");
    }

    @Override
    public Boolean validSmsCode(String phone, String code) {
        return null;
    }

    @Override
    public AreaDTO getAreaDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDTO", null, ticket, AreaDTO.class, "调用sso获取园区出错");
    }

    @Override
    public AreaDetailDTO getAreaDetailDTO(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDetailDTO", null, ticket, AreaDetailDTO.class, "调用sso获取园区详情出错");
    }

    @Override
    public List<AreaListDTO> getInChargeArea(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getInChargeArea", null, ticket, AreaListDTO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaDTO setDefaultArea(String ticket, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/setDefaultArea", ModelUtil.mapOf("areaId", areaId), ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaDTO getDefaultArea(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaDTO", null, ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> getStaffGroupByAreaList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffGroupByAreaList", null, ticket, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<SsoAreaDTO> getGroupAllArea(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getGroupAll", null, ticket, SsoAreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Map getGroupAllStaff(String ticket, String areaId, String roleId, String realName,
                                       Integer pageNum, Integer pageSize ){
        Map param = new HashMap();
        if (pageNum != null && pageSize != null) {
            param.put("pageNum", pageNum);
            param.put("pageSize", pageSize);
        }
        if (StringUtils.isNotEmpty(areaId)) {
            param.put("areaId", areaId);
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getGroupStaffList", param, ticket, HashMap.class, "调用sso推送消息出错");
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getGroupStaffList",
//                param, ticket, StaffPageDO.class, "调用sso推送消息出错");
    }

    @Override
    public List<String> getNormalStaffIdByArea(String ticket, String areaId) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getNormalStaffIdByArea", ModelUtil.mapOf("areaId", areaId), ticket, String.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffPageDO> getAreaStaffList(String ticket, String realName, String roleId, PagerQuery pagerQuery) {

        Map param = new HashMap();
        if (pagerQuery != null) {
            param.put("pageNum", pagerQuery.getPageNum());
            param.put("pageSize", pagerQuery.getPageSize());
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }

        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffList", param, ticket, StaffPageDO.class, "调用sso推送消息出错");
    }


    @Override
    public Map getAreaStaffs(String ticket, String realName, String roleId, Integer status, PagerQuery pagerQuery) {

        Map param = new HashMap();
        if (pagerQuery != null) {
            param.put("pageNum", pagerQuery.getPageNum());
            param.put("pageSize", pagerQuery.getPageSize());
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }
        if (Objects.isNull(status)){
            status = -1;
        }
        param.put("status", status);

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaStaffs", param, ticket, HashMap.class, "调用sso获取员工列表出错");
    }

    @Override
    public Map getAreaStaffsV2(String ticket, String realName, String roleId, Integer status, String isNotStaffIds, String staffIds, PagerQuery pagerQuery) {
        Map param = new HashMap();
        if (pagerQuery != null) {
            param.put("pageNum", pagerQuery.getPageNum());
            param.put("pageSize", pagerQuery.getPageSize());
        }
        if (StringUtils.isNotEmpty(isNotStaffIds)) {
            param.put("isNotStaffIds", isNotStaffIds);
        }
        if (StringUtils.isNotEmpty(staffIds)) {
            param.put("staffIds", staffIds);
        }
        if (StringUtils.isNotEmpty(roleId)) {
            param.put("roleId", roleId);
        }
        if (StringUtils.isNotEmpty(realName)) {
            param.put("realName", realName);
        }

        param.put("status", status);

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaStaffs", param, ticket, HashMap.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffPageDO> getAreaStaffListByPermission(String ticket, String permission, PagerQuery pagerQuery) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaStaffListByPermission", ModelUtil.mapOf("pageNum", 0, "pageSize", 999, "permission", permission), ticket, StaffPageDO.class, "调用sso推送消息出错");
    }

    @Override
    public AreaSettingDTO getAreaSetting(String label, String areaId) {
        return getAreaSetting(label, GLOBAL_SETTING, areaId);
    }

    public AreaSettingDTO getAreaSetting(String label, String type, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaSetting", ModelUtil.mapOf("label", label, "type", type, "areaId", areaId), null, AreaSettingDTO.class, "调用sso推送消息出错");

    }

    @Override
    public List<AreaSettingDTO> getAllAreaSettings(String areaId, String prefix) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAllAreaSettings", ModelUtil.mapOf("areaId", areaId, "prefix", prefix), null, AreaSettingDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId) {
        return addAreaSetting(key, value, description, extension, areaId, GLOBAL_SETTING);
    }

    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId, String type) {
        Map map = new HashMap();
        map.put("key", key);
        map.put("areaId", areaId);
        map.put("value", value);
        map.put("description", description);
        map.put("extension", extension);
        map.put("type", type);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaSetting", map, null, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId) {
        return addAreaSettings(keys, values, description, extension, areaId, GLOBAL_SETTING);
    }

    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId, String type) {
        Map map = new HashMap();
        map.put("key", keys);
        map.put("areaId", areaId);
        map.put("value", values);
        map.put("description", description);
        map.put("extension", extension);
        map.put("type", type);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addAreaSettings", map, null, Integer.class, "调用sso推送消息出错");

    }


    public static String getTermType(int term, String platformId) {
        String retPlatformId = null;

        for (int i = 0; i < TERM_MAP.length; i++){
            String[] arr = TERM_MAP[i];
            for (int j = 0; j < arr.length; j++){
                if (arr[j].equals(platformId)){
                    if (term >= 0 && term < arr.length) {
                        retPlatformId = arr[term];
                    }
                    break;
                }
            }
        }

        if (StringUtils.isBlank(retPlatformId)){
            return DEFAULT_TERM_WEB;
        }

        return retPlatformId;
    }



    @Override
    public List<DictDataDTO> getDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getDictData", map, ticket, DictDataDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Integer addDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/addDictData", map, ticket, Integer.class, "调用sso推送消息出错");
    }

    @Override
    public Integer delDictData(String ticket, String dictCode) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/delDictData", ModelUtil.mapOf("dictCode", dictCode), ticket, Integer.class, "调用sso推送消息出错");

    }

    @Override
    public Integer updateDictData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/updateDictData", map, ticket, Integer.class, "调用sso推送消息出错");
    }

    @Override
    public DictDataDTO dictCodeByDictData(String ticket, String dictCode) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/dictCodeByDictData", ModelUtil.mapOf("dictCode", dictCode), ticket, DictDataDTO.class, "调用sso推送消息出错");
    }

    @Override
    public Map getStaffNameAndAreaName(String staffId, String areaId) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getStaffNameAndAreaName", ModelUtil.mapOf("staffId", staffId, "areaId", areaId), null, Map.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> areasByLocation(float lat, float lon, Integer num) {
        Map map = new HashMap();
        map.put("lat", lat);
        map.put("lon", lon);
        map.put("num", num);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/areasByLocation", map, null, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> areasByLocation(String pcaCode, String pcaName) {
        Map map = new HashMap();
        map.put("pcaCode", pcaCode);
        map.put("pcaName", pcaName);
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/areasByLocationLike", map, null, AreaDTO.class, "调用sso推送消息出错");

    }

    @Override
    public List<AreaStaffDTO> getStaffAreaList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffAreaList", null, ticket, AreaStaffDTO.class, "调用sso推送消息出错");

    }

    @Override
    public boolean isData(String ticket, DictDataDTO dictData) {
        Map map = JSON.parseObject(JSON.toJSONString(dictData), Map.class);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/isData", map, ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public boolean isDataList(String ticket, List<DictDataDTO> dataDTOS) {
//        JSONArray json = JSONArray.(dataDTOS);
        String dictData = JSON.toJSONString(dataDTOS);
//        String  dictData = json.toString();
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/isDataList", ModelUtil.mapOf("dictData", dictData), ticket, Boolean.class, "调用sso推送消息出错");
    }

    @Override
    public List<StaffInfoDTO> getStaffInfoList(String ticket, List<String> staffIds) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/staffInfoList", ModelUtil.mapOf("staffIds", staffIds), ticket, StaffInfoDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<GroupDTO> getStaffGroupList(String ticket) {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getStaffGroupList", null, ticket, GroupDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> getAllArea() {
        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAllArea", null, null, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public List<AreaDTO> getAreaName(String name) {
         return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getAreaName", ModelUtil.mapOf("name", name), null, AreaDTO.class, "调用sso推送消息出错");
    }

    @Override
    public String getAreaGroupAdmin(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaGroupAdmin", null, ticket, String.class, "调用sso推送消息出错");
    }

    @Override
    public String getAreaGroupId(String ticket) {
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getAreaGroupId", null, ticket, String.class, "调用sso推送消息出错");
    }

    @Override
    public AppEditionDTO getEditionCode(String ticket,String appId, String appVersion, Integer type,String wgtVersion) {
        Map map = new HashMap();
        map.put("appId", appId);
        map.put("appVersion", appVersion);
        map.put("type", type);
        map.put("wgtVersion", wgtVersion);
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getEditionCode",
                map, ticket, AppEditionDTO.class, "调用sso推送消息出错");
    }

    @Override
    public StatusResponse saveOrUpdatePerformance(String ticket,PerformanceDetailPO performanceDetailPO) {
        Map param = new HashMap();
        String s = JSON.toJSONString(performanceDetailPO);
        param.put("performanceDetailStr",s);
        HashMap map = RemoteCallUtil.call(ssoServerUrl + "/api/sso/performance/saveOrUpdatePerformance", param, ticket, HashMap.class, "调用sso绩效考核新增或编辑出错");
        return StatusResponse.success(map);
    }

    @Override
    public PerformanceDetailPO detail(PerformanceQueryPO performanceQueryPO) {
        Map param = new HashMap();
        param.put("month",performanceQueryPO.getMonth());
        param.put("year",performanceQueryPO.getYear());
        param.put("staffId",performanceQueryPO.getStaffId());


        PerformanceDetailPO performanceDetailPO = new PerformanceDetailPO();
        String detailJson = RemoteCallUtil.call(ssoServerUrl + "/api/sso/performance/detail", param, null, String.class, "调用sso绩效考核详情出错");
        JSONObject jsonObject = JSONObject.parseObject(detailJson);
        performanceDetailPO.setId(jsonObject.getString("id"));
        performanceDetailPO.setStaffId(jsonObject.getString("staffId"));
        performanceDetailPO.setPerformanceId(jsonObject.getString("jsonObject"));
        performanceDetailPO.setYear(jsonObject.getInteger("year"));
        performanceDetailPO.setMonth(jsonObject.getInteger("month"));
        performanceDetailPO.setTeachingAbility(jsonObject.getBigDecimal("teachingAbility"));
        performanceDetailPO.setWorkingAttitude(jsonObject.getBigDecimal("workingAttitude"));
        performanceDetailPO.setProfessional(jsonObject.getBigDecimal("professional"));
        performanceDetailPO.setOther(jsonObject.getBigDecimal("other"));
        performanceDetailPO.setParentalSatisfaction(jsonObject.getInteger("parentalSatisfaction"));
        performanceDetailPO.setFinalScore(jsonObject.getBigDecimal("finalScore"));
        performanceDetailPO.setComment(jsonObject.getString("comment"));

        return performanceDetailPO;

    }

    /**
     * 列表查询
     * @return
     */
    @Override
    public Map performanceList(String ticket, PerformanceQueryPO performanceQueryPO) {
        Map param = new HashMap();
        if (performanceQueryPO != null) {
            param.put("pageNum", performanceQueryPO.getPageNum());
            param.put("pageSize", performanceQueryPO.getPageSize());
        }
        if (StringUtils.isNotEmpty(performanceQueryPO.getAreaId())) {
            param.put("areaId", performanceQueryPO.getAreaId());
        }
        if (StringUtils.isNotEmpty(performanceQueryPO.getStaffName())) {
            param.put("staffName", performanceQueryPO.getStaffName());
        }
        if (!Objects.isNull(performanceQueryPO.getYear())){
            param.put("year", performanceQueryPO.getYear());
        }

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/performance/performanceList", param, ticket, HashMap.class, "调用sso绩效考核列表出错");
    }

    /**
     * 删除
     * @return
     */
    @Override
    public Map remove(String id) {

        Map param = new HashMap();
        param.put("id",id);

        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/performance/remove", param, null, HashMap.class, "调用sso绩效考核详情出错");
    }

    /**
     * 导出
     * @param response
     * @param ticket
     * @param performanceQueryPO
     * @return
     */
    @Override
    public List<PerformanceExcelPO> exportPerformance(HttpServletResponse response, String ticket, PerformanceQueryPO performanceQueryPO) {
        performanceQueryPO.setPageNum(0);
        performanceQueryPO.setPageSize(9999);
        Map pageMap = this.performanceList(ticket, performanceQueryPO);
        List<PerformanceExcelPO> excelPOList = new LinkedList<>();
        // 获取 content 并检查类型
        Object content = pageMap.get("content");
        if (!(content instanceof List)) { // 仅检查是否为 List 类型
            throw new IllegalStateException("Invalid content type in pageMap");
        }

        // 强制转换为原始 List 类型（非泛型）
        List<?> contentList = (List<?>) content;

        // 遍历时检查元素类型
        for (Object sourceObj : contentList) {
            if (sourceObj == null) continue;

            // 关键：检查元素是否为 Map 类型（而非直接当 POJO 处理）
            if (!(sourceObj instanceof Map)) {
                throw new IllegalArgumentException("Content item is not a Map");
            }

            // 将 Map 转换为目标对象（此处需要具体实现）
            PerformanceExcelPO targetObj = convertMapToPojo((Map<?, ?>) sourceObj);
            excelPOList.add(targetObj);
        }

        return excelPOList;
    }

    @Override
    public List<TeacherDO> getTeacherByClassId(String classId) {
        Map param = new HashMap();
        param.put("classId",classId);


        List<TeacherDO> list = RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/getTeacherByClassId",
                param, null, TeacherDO.class, "调用sso班级教师id出错");

        return list;

    }

    @Override
    public String create1(CreateStaff createStaff) {
        Map map = new HashMap();
        map.put("mobile", createStaff.getMobile());
        map.put("password", createStaff.getPassword());
        map.put("username", createStaff.getUsername());
        map.put("realName", createStaff.getRealName());
        map.put("gender", createStaff.getGender());
        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/staff/create", map, null, String.class, "调用sso推送消息出错");
    }


    private PerformanceExcelPO convertMapToPojo(Map<?, ?> map) {
        PerformanceExcelPO po = new PerformanceExcelPO();
        // 手动映射字段（假设 map 的 key 是 String 类型）
        po.setStaffName((String) map.get("staffName"));
        po.setJanuary(convertToBigDecimal(map.get("january")));
        po.setFebruary(convertToBigDecimal(map.get("february")));
        po.setMarch(convertToBigDecimal(map.get("march")));
        po.setApril(convertToBigDecimal(map.get("april")));
        po.setMay(convertToBigDecimal(map.get("may")));
        po.setJune(convertToBigDecimal(map.get("june")));
        po.setJuly(convertToBigDecimal(map.get("july")));
        po.setAugust(convertToBigDecimal(map.get("august")));
        po.setSeptember(convertToBigDecimal(map.get("september")));
        po.setOctober(convertToBigDecimal(map.get("october")));
        po.setNovember(convertToBigDecimal(map.get("november")));
        po.setDecember(convertToBigDecimal(map.get("december")));
        // 添加空值检查和非空断言
//        if (map.containsKey("field3")) {
//            po.setField3((LocalDate) map.get("field3"));
//        }
        return po;
    }


    private BigDecimal convertToBigDecimal(Object value) {
        if (value == null) {
            return null;
        }
        if (value instanceof Number) {
            return BigDecimal.valueOf(((Number) value).doubleValue());
        } else if (value instanceof String) {
            try {
                return new BigDecimal((String) value);
            } catch (NumberFormatException e) {
            }
        }
        return null;
    }


    //public static final String KEY = "matt";


//    @Override
//    public Map getPermissionInfo(String ticket, String platformId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/permission_info?", ModelUtil.mapOf("platformId", platformId), ticket, Map.class, "调用sso获取用户权限出错");
//    }
//
//    @Override
//    public Map getPermissionInfoV2(String ticket, String platformId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/permission_info_v2", ModelUtil.mapOf("platformId", platformId), ticket, Map.class, "调用sso获取用户权限出错");
//    }
//
//    @Override
//    public StaffBaseDTO getBaseInfo(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/base_info", null, ticket, StaffBaseDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public Map getInfo(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/info", null, ticket, Map.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTO(String ticket) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/get_staff_dto?", null, ticket, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTOById(String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_dto", ModelUtil.mapOf("staffId", staffId), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public StaffDTO getStaffDTOByPhone(String phone) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_staff_dto_by_phone", ModelUtil.mapOf("phone", phone), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffDTO> getStaffDTOList(String[] ids) {
//        String temp = Lists.newArrayList(ids).toString();
//        String id = temp.substring(1, temp.length() - 1);
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/list_by_ids", ModelUtil.mapOf("ids", id), null, StaffDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffAreaDTO> getStaffByPlatformAndRoleAndArea(String platformId, String[] roleCode, String areaId) {
//        String temp = Lists.newArrayList(roleCode).toString();
//        String roleList = temp.substring(1, temp.length() - 1);
//        Map params = ModelUtil.mapOf(Lists.newArrayList("platformId", "roleCode", "areaId"), Lists.newArrayList(platformId, roleList, areaId));
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/get_staff_by_role", params, null, StaffAreaDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public List<StaffAreaDTO> getStaffExcludeRole(String platformName, String[] roleCode, String ticket) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("platformName", "roleCode"), Lists.newArrayList(platformName, Lists.newArrayList(roleCode)));
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/exclude_role", params, ticket, StaffAreaDTO.class, "调用sso获取用户信息出错");
//    }
//
//    @Override
//    public Boolean send_sms(String mobile) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/send_sms", ModelUtil.mapOf("phone", mobile), null, Boolean.class, "调用sso发送短信出错");
//    }
//
//    @Override
//    public String padDingDingLogin(String dingDingCode, String ip) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/ding_ding_login", ModelUtil.mapOf("value", dingDingCode, "ip", ip), null, String.class, "调用sso钉钉登录出错");
//    }
//
//    @Override
//    public String padPasswordLogin(String staffId, String simplePassword, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("staffId", "password", "ip"), Lists.newArrayList(staffId, simplePassword, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/pass_login", params, null, String.class, "调用sso密码登录出错");
//    }
//
//    @Override
//    public String padCodeLogin(String mobile, String code, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("mobile", "value", "ip"), Lists.newArrayList(mobile, code, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/code_login", params, null, String.class, "调用sso手势密码登录出错");
//    }
//
//    @Override
//    public Map padResetPassword(String ticket, String password) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/reset_password", ModelUtil.mapOf("password", password), ticket, Map.class, "调用sso重置密码出错");
//    }
//
//    @Override
//    public List<AreaDTO> getAllArea() {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/un_login/get_all_area", null, null, AreaDTO.class, "调用sso获取所有园区出错");
//    }
//
//    @Override
//    public AreaDTO getAreaById(String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_area", ModelUtil.mapOf("areaId", areaId), null, AreaDTO.class, "调用sso获取园区信息出错");
//    }
//
//    @Override
//    public List<Map> getInChargeArea(String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/in_charge_area", null, ticket, Map.class, "调用sso获取负责园区出错");
//    }
//
//    @Override
//    public Boolean changeArea(String ticket, String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/change_area", ImmutableMap.of("areaId", areaId), ticket, Boolean.class, "调用sso修改园区出错");
//    }
//
//    @Override
//    public Map submitDeviceInfo(String deviceId, String systemName, String platform, String version) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("deviceId", "systemName", "platform", "version"), Lists.newArrayList(deviceId, systemName, platform, version));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/device_info", params, null, Map.class, "调用sso获取版本信息出错");
//    }
//
//    @Override
//    public Boolean modifyHeadImg(String ticket, String imgUrl) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/modify_head_img", ModelUtil.mapOf("imgUrl", imgUrl), ticket, Boolean.class, "调用sso修改头像出错");
//    }
//
////    @Override
////    public String getYinShiToken() {
////        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_yin_shi_token", null, null, String.class, "调用sso获取萤石云token出错");
////    }
//
//    @Override
//    public String getAreaYinShiToken(String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_area_yin_shi_token",  ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取萤石云token出错");
//    }
//
//    @Override
//    public StaffRoleDO getStaffRole(String ticket) {
//        StaffRoleDO staffRoleDO = new StaffRoleDO();
//        HashMap call = RemoteCallUtil.call(ssoServerUrl + "/api/sso/phone/un_login/getStaffRole", ImmutableMap.of("ticket", ticket), null, HashMap.class, "获取用户角色出错");
//        System.out.println("call:"+call);
//        staffRoleDO = StaffRoleDO.of(call);
//        return staffRoleDO;
//    }
//
//    @Override
//    public StaffRoleDO getStaffRoleByStaffId(String staffId) {
//        StaffRoleDO staffRoleDO = new StaffRoleDO();
//        HashMap call = RemoteCallUtil.call(ssoServerUrl + "/api/sso/phone/un_login/getStaffRoleByStaffId", ImmutableMap.of("staffId", staffId), null, HashMap.class, "获取用户角色出错");
//        System.out.println("==call:"+call);
//        staffRoleDO = StaffRoleDO.of(call);
//        return staffRoleDO;
//    }
//
//    @Override
//     public List<String> getLeaderByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getAreaLeader", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区负责人出错");
//    }
//    @Override
//    public List<String> getLeaderStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getLeaderStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区负责人出错");
//    }
//
//
//    @Override
//    public List<String> getStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区员工出错");
//    }
//    //查询某园所未删除 未离职状态的员工ID
//    @Override
//    public List<String> getNomarlStaffIdByArea(String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/phone/un_login/getNomarlStaffIdByArea", ModelUtil.mapOf("areaId", areaId), null, String.class, "调用sso获取园区员工出错");
//    }
//
//    @Override
//    public List<PlatformMenuDto> getPlatformMenu(String ticket, String platformId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/web/staff/platform_menu", ModelUtil.mapOf("platformId", platformId), ticket, PlatformMenuDto.class, "调用sso获取更新按钮信息出错");
//    }
//
//    @Override
//    public AreaSettingDTO getAreaSetting(String key, String areaId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/area_setting", ModelUtil.mapOf("key", key, "areaId", areaId), null, AreaSettingDTO.class, "调用sso获取园区设置");
//    }
//
//    @Override
//    public List<AreaSettingDTO> getAllAreaSettings(String areaId, String prefix){
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/all_area_settings", ModelUtil.mapOf("prefix", prefix, "areaId", areaId), null, List.class, "调用sso获取园区设置");
//    }
//
//    @Override
//    public Boolean addAreaSetting(String key, String value, String description, String extension, String areaId) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "description", "extension", "areaId"), Lists.newArrayList(key, value, description, extension, areaId));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/add_area_setting", params, null, Boolean.class, "调用sso设置园区配置信息出错");
//    }
//
//    @Override
//    public Integer addAreaSettings(String keys, String values, String description, String extension, String areaId) {
//        Map params = null;
//        if(StringUtils.isEmpty(extension) || StringUtils.isEmpty(description)){
//            params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "areaId"), Lists.newArrayList(keys, values, areaId));
//        }else{
//            params = ModelUtil.mapOf(Lists.newArrayList("key", "value", "description", "extension", "areaId"), Lists.newArrayList(keys, values, description, extension, areaId));
//        }
//
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/add_area_settings", params, null, Integer.class, "调用sso设置园区配置信息出错");
//    }
//
//    @Override
//    public List<WorkDayDTO> getWorkDayList(String begin, String end) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/work_day_list", ModelUtil.mapOf("begin", begin, "end", end), null, WorkDayDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//    public StaffRoleDTO getRoleByPlatform(String ticket, Integer platformType) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/staff/get_staff_role", ModelUtil.mapOf("platformType", platformType), ticket, StaffRoleDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public boolean sendPushByAlias(PushMsgVo pushMsg, String appKey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVo", JsonUtil.toJson(pushMsg), "appKey", appKey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/alia", params, null, Boolean.class, "调用sso推送消息出错");
//    }
//
//    @Override
//    public boolean sendPushByListAlias(List<PushMsgVo> pushMsg, String appKey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVos", JsonUtil.toJson(pushMsg), "appKey", appKey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/alias", params, null, Boolean.class, "调用sso推送消息出错");
//
//    }
//
//    @Override
//    public boolean sendPushByTags(List<PushMsgVo> pushMsgVos, String appkey, String masterSecret) {
//        Map params = com.matt.commons.utils.ModelUtil.mapOf("msgVos", JsonUtil.toJson(pushMsgVos), "appKey", appkey, "masterSecret", masterSecret);
//        return RemoteCallUtil.call(ssoServerUrl + "/api/push/tags", params, null, Boolean.class, "调用sso推送消息出错");
//    }
//
//    @Override
//    public Object getAllAreaWithType() {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/get_area_with_type", null, null, ArrayList.class, "sso通信出错");
//    }
//
//    @Override
//    public List<RelStaffPositionDTO> getAllStaffPositionInfo(String positionCode) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_all_staff_by_code", ModelUtil.mapOf("positionCode", positionCode), null, RelStaffPositionDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//       public List<RelStaffPositionDTO> getAreaStaffPositionInfo(String positionCode, String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_area_staff_by_code", ModelUtil.mapOf("positionCode", positionCode), ticket, RelStaffPositionDTO.class, "调用sso获取工作日出错");
//    }
//
//    @Override
//    public List<RelStaffPositionPlatformDTO> getStaffPositionList(String platformId, String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_staff_position_list", ModelUtil.mapOf("platformId", platformId), ticket, RelStaffPositionPlatformDTO.class, "调用sso获取用户岗位列表出错");
//    }
//
//
//    @Override
//    public Map getContentDownload(String ticket, Integer page, Integer size) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_download_list", ModelUtil.mapOf("page", page, "size", size), ticket, Map.class, "调用sso获取下载列表失败");
//    }
//
//    @Override
//    public Boolean getIsTestUser(String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/getIsTestUser", ModelUtil.mapOf("staffId", staffId), CommonConstant.AUTH_VALUE, Boolean.class, "调用sso查询是否是外部测试用户失败");
//    }
//
//    @Override
//    public String phonePassLogin(String mobile, String password, String ip) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("mobile", "password", "ip"), Lists.newArrayList(mobile, password, ip));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/pad/un_login/phoneLogin", params, null, String.class, "调用sso手机登录出错");
//    }
//
//    @Override
//    public Boolean validSmsCode(String phone, String code) {
//        Map params = ModelUtil.mapOf(Lists.newArrayList("phone", "value"), Lists.newArrayList(phone, code));
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/web/un_login/validSmsCode", params, null, Boolean.class, "调用短信验证码校验接口出错");
//    }
//
//
//    @Override
//    public StaffPositionDTO getStaffPositionInfo(String ticket,String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/staff_position_by_staffId", ModelUtil.mapOf("staffId", staffId),ticket, StaffPositionDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public DefaultStaffPositionDTO getDefaultStaffPositionInfo(String ticket,String staffId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/get_default_staff_position", ModelUtil.mapOf("staffId", staffId, "platformId", com.matt.foundation.constant.CommonConstant.TEACH_PLATFORM_ID),ticket, DefaultStaffPositionDTO.class, "调用sso获取相关角色信息出错");
//    }
//
//    @Override
//    public Map setDefaultStaffPosition(String ticket,String staffId,String deafultPositionId) {
//        return RemoteCallUtil.call(ssoServerUrl + "/api/sso/other_system/set_default_staff_position", ModelUtil.mapOf("staffId", staffId,"positionId",deafultPositionId),ticket, Map.class, "设置用户默认刚问出错");
//    }
//
//    @Override
//    public List<PlatformPositionDTO> getPlatformPositionList(String ticket) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_platfrom_position_list", null, ticket, PlatformPositionDTO.class, "获取平台岗位列表出错");
//    }
//
//    @Override
//    public List<PlatformRoleDO> getAreaStaffInfo(String ticket,String platformId,String areaId) {
//        return RemoteCallUtil.callOfList(ssoServerUrl + "/api/sso/other_system/get_area_staff_info", ModelUtil.mapOf("platformId", platformId,"areaId",areaId), ticket, PlatformRoleDO.class, "调用sso获取工作日出错");
//    }
}
